package com.winchain.chainbill.asset.biz.query.controller;

import com.shell.bee.base.annotation.Logging;
import com.shell.bee.base.utils.StringUtil;
import com.shell.bee.mvc.controller.BaseController;
import com.shell.bee.persistence.model.PageLimit;
import com.shell.framework.utils.CommonDataUtil;
import com.winchain.chainbill.asset.biz.query.service.AssetsQueryService;
import com.winchain.chainbill.asset.biz.query.vo.Assets;
import com.winchain.chainbill.asset.biz.query.vo.CreditAssetVo;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class AssetQueryController
  extends BaseController
{
  @Autowired
  private AssetsQueryService assetsQueryService;
  
  @RequestMapping
  @ResponseBody
  @Logging(module="��������", methods="������������")
  public Assets selectAssets()
    throws Exception
  {
    Assets assets = this.assetsQueryService.query(CommonDataUtil.getCurEntId());
    return assets;
  }
  
  @RequestMapping
  @ResponseBody
  @Logging(module="��������", methods="������������")
  public List<CreditAssetVo> selectCreditAsset(PageLimit limit, CreditAssetVo creditAssetVo)
    throws Exception
  {
    creditAssetVo.setFinId(CommonDataUtil.getCurEntId());
    if (StringUtil.notEmpty(creditAssetVo.getSearchStr())) {
      creditAssetVo.setSearchStr("%" + creditAssetVo.getSearchStr() + "%");
    }
    List<CreditAssetVo> assets = this.assetsQueryService.selectCreditAsset(limit, creditAssetVo);
    
    return assets;
  }
}
